<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="/website/common/base.jsp" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>购物车</title>
    <%@ include file="/website/common/common.jsp" %>
    <link href="${webctx }/css/payment.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx }/plugins/msgTips/css/css.css" rel="stylesheet" type="text/css"/>

    <style>
        button.btn_loading {
            background: #0daeff url("${webctx }/images/btn_loading.gif") no-repeat center center;
            font-size: 0;
        }

        .ft-hd-nav {
            padding-top: 40px;
        }

        #Warp_pay {
            overflow: visible;
        }
    </style>

</head>
<body>
<%@ include file="/website/common/top-new.jsp" %>

<c:choose>
    <c:when test="${count > 0}">
        <div id="Warp_pay" class="new-shopping-cart">
            <div id="wrap-head">
                <div class="head wid990 clearfix">
                    <div class="logo"><a href="${ctx }/website/index.jsp"><img src="${webctx }/images/logo.png"/></a>
                    </div>
                    <div class="head-message">购物车</div>
                    <div class="search-input">
                        <div class="input-box">
                            <form action="" method="get" onsubmit="return false;">
                                <input class="input-md" id="topsearchtitle" name="topsearchtitle"
                                       onfocus="curinutfocus='search'" onblur="curinutfocus=''" type="text"
                                       style="height:30px; line-height:26px;" value="${querylike }"
                                       placeholder="输入商品名称，通用名，商品编号，生产厂家"/>
                            </form>
                        </div>
                        <button type="submit" class="search-btn" onclick="searchProduct()"></button>
                    </div>
                </div>
            </div>

            <div class="cart-con wid990">
                    <%-- <div class="tit">温馨提示：订单满 <em class="cart-red">500</em> 元方可支持免费配送</div>--%>
                <div class="cart-list">
                    <div class="cart-list-tit">
                        <ul>
                            <li class="th-chk">
                                <div class="cart-checkbox allbox">
                                    <input name="cartcheckbox" type="checkbox" value=""/>
                                    <label class="J_select">
                                        <span class="chk-ico"></span> 全选
                                    </label>
                                </div>
                            </li>
                            <li class="shop-info">商品信息</li>
                            <li class="shop-price">单价（元）</li>
                            <li class="shop-amount">数量</li>
                            <li class="shop-sum">小计（元）</li>
                            <li class="shop-op">
                                <c:choose>
                                    <c:when test="${not empty coupons}">
                                        <div class="coupon-btn">
                                            <span onclick="cl_coupon(this)">领优惠券</span>
                                            <!-- 领取优惠券弹窗 -->
                                            <div class="get-coupon" style="display: none;">
                                                <span class="ico-coupon-popup"></span><!-- 小图标 -->
                                                <div class="get-coupon-tit">已选商品可用券</div>
                                                <ul>
                                                    <c:forEach items="${coupons}" var="coupon">
                                                        <li class="clearfix">
                                                            <div class="get-coupou-price">
                                                                ￥<span><fmt:formatNumber value="${coupon.offerMoney}" pattern="#0.##"/></span>
                                                            </div>
                                                            <div class="get-coupon-text">
                                                                <p class="txt-p1">${coupon.name}</p>
                                                                <p class="txt-p2">满${coupon.minMoney}可使用</p>
                                                            </div>
                                                            <c:choose>
                                                                <c:when test="${coupon.available}">
                                                                    <a id="click${coupon.id}"
                                                                       href="javascript:getCoupon('${coupon.id}');"
                                                                       class="get-coupon-btn">领取</a>
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <a href="javascript:void(0);"
                                                                       class="get-coupon-btn">已领取</a>
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </li>
                                                    </c:forEach>
                                                </ul>
                                            </div>
                                        </div>
                                    </c:when>
                                    <c:otherwise>操作</c:otherwise>
                                </c:choose>
                            </li>
                        </ul>
                    </div>
                    <c:if test="${not empty money_off}">
                        <c:forEach items="${money_off}" var="item">
                            <div class="cart-item cart-item-bor" id="${item.promotionId}">
                                <div class="item-tit">
                                    <span>满减</span>
                                    <c:choose>
                                        <c:when test="${item.available}">
                                            活动已购满<fmt:formatNumber value="${item.standardMoney}" pattern="#0.##"/>,
                                            <em class="cart-red">
                                                <c:choose>
                                                    <c:when test="${not empty item.discountRate}">
                                                        已打<fmt:formatNumber value="${item.discountRate}"
                                                                            pattern="#0.##"/>折
                                                    </c:when>
                                                    <c:otherwise>
                                                        已减<fmt:formatNumber value="${item.discountMoney}"
                                                                            pattern="#0.##"/>元
                                                    </c:otherwise>
                                                </c:choose>
                                            </em>
                                        </c:when>
                                        <c:otherwise>
                                            活动
                                            <c:forEach var="rule" items="${item.items}">
                                                满<fmt:formatNumber value="${rule.offMoney}" pattern="#0.##"/>
                                                <c:choose>
                                                    <c:when test="${not empty rule.discountRate}">
                                                        打${rule.discountRate}折,
                                                    </c:when>
                                                    <c:otherwise>
                                                        减<fmt:formatNumber value="${rule.discountMoney}"
                                                                           pattern="#0.##"/>,
                                                    </c:otherwise>
                                                </c:choose>
                                            </c:forEach>
                                        </c:otherwise>
                                    </c:choose>
                                    <div class="item-sum item-sum-lig">
                                        <em style="display: none"
                                            id="price${item.promotionId}">${item.totalPrice}</em>
                                        <p style="padding-left: 14px">
                                            ￥<fmt:formatNumber value="${item.minuendPrice}" pattern="#0.##"/>
                                        </p>
                                        <c:if test="${item.available}">
                                            <p class="cart-red">减￥<fmt:formatNumber value="${item.discountMoney}"
                                                                                    pattern="#0.##"/></p>
                                        </c:if>
                                    </div>
                                </div>
                                <div class="item-drug-list">
                                    <c:forEach items="${item.products}" var="product">
                                        <c:choose>
                                            <c:when test="${not empty product.giftType}">
                                                <c:if test="${product.gift}">
                                                    <div class="drug-item give-shop clearfix">
                                                        <ul>
                                                            <!-- 默认不能选 -->
                                                            <li class="td td-chk th-disabled">
                                                                <span></span>
                                                            </li>
                                                            <li class="drug-img"><a
                                                                    href="${ctx}/product/info?priceid=${product.id}"
                                                                    target="_blank"><img
                                                                    src="<%=getRandomFileserver()%>${product.photo}"
                                                                    alt=""
                                                                    onerror="this.src='/website//images/noimg.jpg'"></a>
                                                            </li>
                                                            <li class="drug-info">
                                                                <p class="drug-info-name">
                                                                    <span class="give-sp">赠品</span>${product.name}
                                                                </p>
                                                                <p class="ph drug-info-company">
                                                                    厂家： ${product.b_chanjia}</p>
                                                                <p class="ph drug-info-size">规格： ${product.b_guige}</p>
                                                            </li>
                                                            <li class="drug-price">
                                                                <p>￥0.00</p>
                                                            </li>
                                                            <li class="drug-amount td-amount">
                                                                <p>${product.buyNum}</p>
                                                                <c:if test="${product.shortage}">
                                                                    <p class="drug-repertory cart-red">库存不足</p>
                                                                </c:if>
                                                            </li>
                                                            <li class="drug-sum">
                                                                <p>￥0.00</p>
                                                            </li>
                                                            <li class="drug-op">
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </c:if>
                                            </c:when>
                                            <c:otherwise>
                                                <div class="drug-item clearfix">
                                                    <ul class="clearfix">
                                                        <li class="td td-chk">
                                                            <div class="cart-checkbox productbox checked">
                                                                <input name="cartcheckbox" type="checkbox"
                                                                       onclick="toggleChecked(event,'money_off',${item.promotionId},${product.cartId},${product.id},this);"
                                                                       value="${product.cartId}">
                                                                <label class="J_select">
                                                                </label>
                                                            </div>
                                                        </li>
                                                        <li class="drug-img"><a
                                                                href="${ctx}/product/info?priceid=${product.id}"
                                                                target="_blank"><img
                                                                src="<%=getRandomFileserver()%>${product.photo}"
                                                                alt=""
                                                                onerror="this.src='/website//images/noimg.jpg'"></a>
                                                        </li>
                                                        <li class="drug-info">
                                                            <p class="drug-info-name">${product.name}</p>
                                                            <p class="ph drug-info-company">厂家： ${product.b_chanjia}</p>
                                                            <p class="ph drug-info-size">规格： ${product.b_guige}</p>
                                                        </li>
                                                        <li class="drug-price">
                                                            <p>￥<fmt:formatNumber value="${product.price}"
                                                                                  pattern="#0.##"/></p>
                                                            <c:if test="${product.flashSale && not empty product.flashSaleAvailableInventory}">
                                                                <p class="cart-red">
                                                                    限购${product.flashSaleAvailableInventory}件</p>
                                                            </c:if>
                                                        </li>
                                                        <li class="drug-amount td-amount">
                                                            <div class="buy-Num-bd across">
                                                                <input cartid="${product.cartId}" id="${product.id}"
                                                                       name="buynumInp" type="text"
                                                                       class="buy-numInp"
                                                                       style="float:left;height:26px;line-height:26px;"
                                                                       value="${product.buyNum}"
                                                                       onblur="inputAmount('money_off', ${item.promotionId}, ${product.cartId}, ${product.id}, this);"
                                                                       maxnum="${product.amount}">
                                                                <span class="btn-reduce"
                                                                      onclick="lessenamount('money_off', ${item.promotionId}, ${product.cartId}, ${product.id}, this);">-</span>
                                                                <span class="btn-add"
                                                                      onclick="addamount('money_off', ${item.promotionId}, ${product.cartId}, ${product.id}, this);">+</span>
                                                                <span class="buy-txt">${product.unit}</span>
                                                            </div>
                                                            <p class="drug-repertory">库存：
                                                                <c:choose>
                                                                    <c:when test="${product.amount>100}">>100</c:when>
                                                                    <c:when test="${product.amount<=0}">无</c:when>
                                                                    <c:otherwise>${product.amount }</c:otherwise>
                                                                </c:choose>
                                                            </p>
                                                        </li>
                                                        <li class="drug-sum">
                                                            <p>
                                                                ￥<span id="xiaoji${product.cartId}"><fmt:formatNumber
                                                                    value="${product.totalPrice}"
                                                                    pattern="#0.##"/></span>
                                                            </p>
                                                        </li>
                                                        <li class="drug-op">
                                                            <c:choose>
                                                                <c:when test="${product.often}">
                                                                    <p isadd="false"
                                                                       onclick="addOften(${product.id},this)">
                                                                        已收藏</p>
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <p isadd="true"
                                                                       onclick="addOften(${product.id},this)">收藏</p>
                                                                </c:otherwise>
                                                            </c:choose>
                                                            <p onclick="delCart(${product.cartId});">删除</p>
                                                        </li>
                                                    </ul>
                                                    <div class="cl"></div>
                                                    <c:if test="${product.buySend}">
                                                        <p class="give-shop-txt">
                                                            <c:choose>
                                                                <c:when test="${product.available}">
                                                                    <em class="cart-red">买送：</em>${product.name} ${product.b_guige}×${product.giftNum}
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <em class="cart-red">买送：</em>买${product.standardNum}送${product.sendNum}
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </p>
                                                    </c:if>
                                                </div>
                                            </c:otherwise>
                                        </c:choose>
                                    </c:forEach>
                                </div>
                            </div>
                        </c:forEach>
                    </c:if>
                    <c:if test="${not empty purchase_gift}">
                        <c:forEach items="${purchase_gift}" var="item">
                            <div class="cart-item cart-item-bor have-give-shop mt-10">
                                <div class="item-tit">
                                    <span>满赠</span>
                                    活动购满<em id="standardMoney${item.promotionId}">
                                    <c:choose>
                                    <c:when test="${not empty item.standardMoney}">
                                    <fmt:formatNumber value="${item.standardMoney}" pattern="#0.##"/></em>元,
                                    </c:when>
                                    <c:otherwise>
                                        ${item.standardAmount}</em>件,
                                    </c:otherwise>
                                    </c:choose>
                                    <em class="cart-red">
                                        <c:if test="${item.hasStandard==true}">
                                        <em id="giftText${item.promotionId}">已获得赠品</em><em
                                            id="number${item.promotionId}">${item.number}</em>件，赠完即止</em>
                                    </c:if>
                                    <c:if test="${item.hasStandard==false}">
                                        <em id="giftText${item.promotionId}">可获得赠品</em><em
                                            id="number${item.promotionId}">${item.number}</em>件，赠完即止</em>
                                    </c:if>
                                    <div class="item-sum">
                                        <p style="padding-left: 14px">
                                            ￥<em id="price${item.promotionId}"><fmt:formatNumber
                                                value="${item.totalPrice}" pattern="#0.##"/></em>
                                        </p>
                                    </div>
                                </div>
                                <div class="item-drug-list" id="${item.promotionId}">
                                    <c:forEach items="${item.products}" var="product">
                                        <c:choose>
                                            <c:when test="${not empty product.giftType}">
                                                <c:if test="${product.gift}">
                                                    <div class="drug-item give-shop clearfix">
                                                        <ul>
                                                            <!-- 默认不能选 -->
                                                            <li class="td td-chk th-disabled">
                                                                <span></span>
                                                            </li>
                                                            <li class="drug-img">
                                                                <a href="${ctx}/product/info?priceid=${product.id}"
                                                                   target="_blank">
                                                                    <img src="<%=getRandomFileserver()%>${product.photo}"
                                                                         alt=""
                                                                         onerror="this.src='/website//images/noimg.jpg'">
                                                                </a>
                                                            </li>
                                                            <li class="drug-info">
                                                                <p class="drug-info-name">
                                                                    <span class="give-sp">赠品</span>${product.name}
                                                                </p>
                                                                <p class="ph drug-info-company">
                                                                    厂家： ${product.b_chanjia}</p>
                                                                <p class="ph drug-info-size">规格： ${product.b_guige}</p>
                                                            </li>
                                                            <li class="drug-price">
                                                                <p>￥0.00</p>
                                                            </li>
                                                            <li class="drug-amount td-amount">
                                                                <p>${product.buyNum}</p>
                                                                <c:if test="${product.shortage}">
                                                                    <p class="drug-repertory cart-red">库存不足</p>
                                                                </c:if>
                                                            </li>
                                                            <li class="drug-sum">
                                                                <p>￥0.00</p>
                                                            </li>
                                                            <li class="drug-op">
                                                            </li>
                                                        </ul>
                                                    </div>
                                                </c:if>
                                            </c:when>
                                            <c:otherwise>
                                                <div class="drug-item clearfix">
                                                    <ul class="clearfix">
                                                        <li class="td td-chk">
                                                            <div class="cart-checkbox productbox checked">
                                                                <input name="cartcheckbox" type="checkbox"
                                                                       onclick="toggleChecked(event,'purchase_gift',${item.promotionId},${product.cartId},${product.id},this);"
                                                                       value="${product.cartId}">
                                                                <label class="J_select">
                                                                </label>
                                                            </div>
                                                        </li>
                                                        <li class="drug-img"><a
                                                                href="${ctx}/product/info?priceid=${product.id}"
                                                                target="_blank"><img
                                                                src="<%=getRandomFileserver()%>${product.photo}"
                                                                alt=""
                                                                onerror="this.src='/website//images/noimg.jpg'"></a>
                                                        </li>
                                                        <li class="drug-info">
                                                            <p class="drug-info-name">${product.name}</p>
                                                            <p class="ph drug-info-company">厂家： ${product.b_chanjia}</p>
                                                            <p class="ph drug-info-size">规格： ${product.b_guige}</p>
                                                        </li>
                                                        <li class="drug-price">
                                                            <p>￥<fmt:formatNumber value="${product.price}"
                                                                                  pattern="#0.##"/></p>
                                                            <c:if test="${product.flashSale && not empty product.flashSaleAvailableInventory}">
                                                                <p class="cart-red">
                                                                    限购${product.flashSaleAvailableInventory}件</p>
                                                            </c:if>
                                                        </li>
                                                        <li class="drug-amount td-amount">
                                                            <div class="buy-Num-bd across">
                                                                <input cartid="${product.cartId}" id="${product.id}"
                                                                       name="buynumInp"
                                                                       type="text"
                                                                       class="buy-numInp"
                                                                       style="float:left;height:26px;line-height:26px;"
                                                                       value="${product.buyNum}"
                                                                       onblur="inputAmount('purchase_gift', ${item.promotionId}, ${product.cartId}, ${product.id}, this);"
                                                                       maxnum="${product.amount}">
                                                                <span class="btn-reduce"
                                                                      onclick="lessenamount('purchase_gift', ${item.promotionId}, ${product.cartId}, ${product.id}, this);">-</span>
                                                                <span class="btn-add"
                                                                      onclick="addamount('purchase_gift', ${item.promotionId}, ${product.cartId}, ${product.id}, this);">+</span>
                                                                <span class="buy-txt">${product.unit}</span>
                                                            </div>
                                                            <p class="drug-repertory">库存：
                                                                <c:choose>
                                                                    <c:when test="${product.amount>100}">>100</c:when>
                                                                    <c:when test="${product.amount<=0}">无</c:when>
                                                                    <c:otherwise>${product.amount }</c:otherwise>
                                                                </c:choose>
                                                            </p>
                                                        </li>
                                                        <li class="drug-sum">
                                                            <p>
                                                                ￥ <span id="xiaoji${product.cartId}"><fmt:formatNumber
                                                                    value="${product.totalPrice}"
                                                                    pattern="#0.##"/></span>
                                                            </p>
                                                        </li>
                                                        <li class="drug-op">
                                                            <c:choose>
                                                                <c:when test="${product.often}">
                                                                    <p isadd="false"
                                                                       onclick="addOften(${product.id},this)">
                                                                        已收藏</p>
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <p isadd="true"
                                                                       onclick="addOften(${product.id},this)">收藏</p>
                                                                </c:otherwise>
                                                            </c:choose>
                                                            <p onclick="delCart(${product.cartId});">删除</p>
                                                        </li>
                                                    </ul>
                                                    <div class="cl"></div>
                                                    <c:if test="${product.buySend}">
                                                        <p class="give-shop-txt">
                                                            <c:choose>
                                                                <c:when test="${product.available}">
                                                                    <em class="cart-red">买送：</em>${product.name} ${product.b_guige}×${product.giftNum}
                                                                </c:when>
                                                                <c:otherwise>
                                                                    <em class="cart-red">买送：</em>买${product.standardNum}送${product.sendNum}
                                                                </c:otherwise>
                                                            </c:choose>
                                                        </p>
                                                    </c:if>
                                                </div>
                                            </c:otherwise>
                                        </c:choose>
                                    </c:forEach>
                                </div>
                            </div>
                        </c:forEach>
                    </c:if>
                    <c:if test="${not empty complex}">
                        <div class="cart-item mt-10">
                            <c:forEach items="${complex}" var="product">
                                <div class="item-drug-list" id="${product.cartId}">
                                    <div class="drug-item clearfix">
                                        <ul class="bor-no clearfix">
                                            <li class="td td-chk">
                                                <div class="cart-checkbox productbox checked">
                                                    <input name="cartcheckbox" type="checkbox"
                                                           onclick="toggleChecked(event,'complex',null,${product.cartId},${product.id},this);"
                                                           value="${product.cartId}">
                                                    <label class="J_select">
                                                    </label>
                                                </div>
                                            </li>
                                            <li class="drug-img"><a
                                                    href="${ctx}/product/info?priceid=${product.id}"
                                                    target="_blank"><img
                                                    src="<%=getRandomFileserver()%>${product.photo}"
                                                    alt=""
                                                    onerror="this.src='/website//images/noimg.jpg'"></a>
                                            </li>
                                            <li class="drug-info">
                                                <p class="drug-info-name">${product.name}</p>
                                                <p class="ph drug-info-company">厂家： ${product.b_chanjia}</p>
                                                <p class="ph drug-info-size">规格： ${product.b_guige}</p>
                                            </li>
                                            <li class="drug-price">
                                                <p>￥<fmt:formatNumber value="${product.price}"
                                                                      pattern="#0.##"/></p>
                                                <c:if test="${product.flashSale && not empty product.flashSaleAvailableInventory}">
                                                    <p class="cart-red">
                                                        限购${product.flashSaleAvailableInventory}件</p>
                                                </c:if>
                                            </li>
                                            <li class="drug-amount td-amount">
                                                <div class="buy-Num-bd across">
                                                    <input cartid="${product.cartId}" id="${product.id}"
                                                           name="buynumInp"
                                                           type="text"
                                                           class="buy-numInp"
                                                           style="float:left;height:26px;line-height:26px;"
                                                           value="${product.buyNum}"
                                                           onkeyup="inputAmount('complex', null, ${product.cartId}, ${product.id}, this);"
                                                           maxnum="${product.amount}">
                                                    <span class="btn-reduce"
                                                          onclick="lessenamount('complex', null, ${product.cartId}, ${product.id}, this);">-</span>
                                                    <span class="btn-add"
                                                          onclick="addamount('complex', null, ${product.cartId}, ${product.id}, this);">+</span>
                                                    <span class="buy-txt">${product.unit}</span>
                                                </div>
                                                <p class="drug-repertory">库存：
                                                    <c:choose>
                                                        <c:when test="${product.amount>100}">>100</c:when>
                                                        <c:when test="${product.amount<=0}">无</c:when>
                                                        <c:otherwise>${product.amount }</c:otherwise>
                                                    </c:choose>
                                                </p>
                                            </li>
                                            <li class="drug-sum">
                                                <p>￥<em id="price${product.cartId}"><fmt:formatNumber
                                                        value="${product.totalPrice}"
                                                        pattern="#0.##"/></em>
                                                </p>
                                            </li>
                                            <li class="drug-op">
                                                <c:choose>
                                                    <c:when test="${product.often}">
                                                        <p isadd="false"
                                                           onclick="addOften(${product.id},this)">
                                                            已收藏</p>
                                                    </c:when>
                                                    <c:otherwise>
                                                        <p isadd="true"
                                                           onclick="addOften(${product.id},this)">收藏</p>
                                                    </c:otherwise>
                                                </c:choose>
                                                <p onclick="delCart(${product.cartId});">删除</p>
                                            </li>
                                        </ul>
                                        <div class="cl"></div>
                                        <c:if test="${product.buySend}">
                                            <p class="give-shop-txt">
                                                <c:choose>
                                                    <c:when test="${product.available}">
                                                        <em class="cart-red">买送：</em>${product.name} ${product.b_guige}×${product.giftNum}
                                                    </c:when>
                                                    <c:otherwise>
                                                        <em class="cart-red">买送：</em>买${product.standardNum}送${product.sendNum}
                                                    </c:otherwise>
                                                </c:choose>
                                            </p>
                                        </c:if>
                                    </div>
                                </div>
                            </c:forEach>
                        </div>
                    </c:if>
                    <c:if test="${not empty list}">
                        <c:forEach items="${list}" var="product">
                            <div class="cart-item mt-10">
                                <div class="item-drug-list" id="${product.cartId}">
                                    <div class="drug-item clearfix">
                                        <ul class="bor-no clearfix">
                                            <li class="td td-chk">
                                                <div class="cart-checkbox productbox checked">
                                                    <input name="cartcheckbox" type="checkbox"
                                                           onclick="toggleChecked(event,'list',null,${product.cartId},${product.id},this);"
                                                           value="${product.cartId}">
                                                    <label class="J_select">
                                                    </label>
                                                </div>
                                            </li>
                                            <li class="drug-img"><a
                                                    href="${ctx}/product/info?priceid=${product.id}"
                                                    target="_blank"><img
                                                    src="<%=getRandomFileserver()%>${product.photo}"
                                                    alt=""
                                                    onerror="this.src='/website//images/noimg.jpg'"></a></li>
                                            <li class="drug-info">
                                                <p class="drug-info-name">${product.name}</p>
                                                <p class="ph drug-info-company">厂家： ${product.b_chanjia}</p>
                                                <p class="ph drug-info-size">规格： ${product.b_guige}</p>
                                            </li>
                                            <li class="drug-price">
                                                <p>￥<fmt:formatNumber value="${product.price}" pattern="#0.##"/></p>
                                            </li>
                                            <li class="drug-amount td-amount">
                                                <div class="buy-Num-bd across">
                                                    <input cartid="${product.cartId}" id="${product.id}"
                                                           name="buynumInp"
                                                           type="text"
                                                           class="buy-numInp"
                                                           style="float:left;height:26px;line-height:26px;"
                                                           value="${product.buyNum}"
                                                           onkeyup="inputAmount('list',null,${product.cartId},${product.id},this);"
                                                           maxnum="${product.amount}">
                                                    <span class="btn-reduce"
                                                          onclick="lessenamount('list',null,${product.cartId},${product.id},this);">-</span>
                                                    <span class="btn-add"
                                                          onclick="addamount('list',null,${product.cartId},${product.id},this);">+</span>
                                                    <span class="buy-txt">${product.unit}</span>
                                                </div>
                                                <p class="drug-repertory">库存：
                                                    <c:choose>
                                                        <c:when test="${product.amount>100}">>100</c:when>
                                                        <c:when test="${product.amount<=0}">无</c:when>
                                                        <c:otherwise>${product.amount }</c:otherwise>
                                                    </c:choose>
                                                </p>
                                            </li>
                                            <li class="drug-sum">
                                                <p>￥<em id="price${product.cartId}"><fmt:formatNumber
                                                        value="${product.totalPrice}" pattern="#0.##"/></em></p>
                                            </li>
                                            <li class="drug-op">
                                                <c:choose>
                                                    <c:when test="${product.often}">
                                                        <p isadd="false" onclick="addOften(${product.id},this)">
                                                            已收藏</p></c:when>
                                                    <c:otherwise>
                                                        <p isadd="true" onclick="addOften(${product.id},this)">
                                                            收藏</p>
                                                    </c:otherwise>
                                                </c:choose>
                                                <p onclick="delCart(${product.cartId});">删除</p>
                                            </li>
                                        </ul>
                                        <div class="cl"></div>
                                    </div>
                                </div>
                            </div>
                        </c:forEach>
                    </c:if>


                </div>
                <div class="cart-ft">
                    <ul class="cart-ft-left">
                        <li class="ft-chk">
                            <div class="cart-checkbox allbox checked">
                                <input name="cartcheckbox" type="checkbox" value="">
                                <label class="J_select"><span class="chk-ico"></span> 全选
                                </label>
                            </div>
                        </li>
                        <li><a href="javascript:void(0);" onclick="delCarts();">删除</a></li>
                    </ul>
                    <ul class="cart-ft-right">
                        <li class="ft-num">
                            <div class="ft-inner">已选商品<strong id="sumnum" style="padding:0 3px"></strong>件</div>
                        </li>
                        <li class="ft-sum">
                            <input type="hidden" name="allTotalPrice" value="${totalPrice}">
                            <div class="ft-inner">合计：<strong id="heji"><fmt:formatNumber value="${totalPrice}"
                                                                                         pattern="#0.##"></fmt:formatNumber></strong>
                                元
                            </div>
                        </li>
                        <li class="ft-btn">
                            <button id="btn_submit_form" onclick="tojies()">结算</button>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </c:when>
    <c:otherwise>
        <div id="Warp_pay">
            <div class="wid990">
                <div class="title"><strong>我的购物车(0)</strong></div>
                <div class="main-txt">
                    <div class="txt-kong">
                        <span class="ico-1"></span>
                        <p>您可以去<a href="${ctx }/website/index.jsp">首页</a>抢购，或者查看<a
                                href="${ctx }/product/favorites">我的收藏</a>
                        </p>
                    </div>
                </div>
                <div class="com-box inner mt-10">
                </div>
            </div>
        </div>
    </c:otherwise>
</c:choose>
<input type="hidden" name="count" value="${count}">
<!-- 弹窗 -->
<div class="put-up-window" style="display: none">
    <div class="put-up-tit">提示</div>
    <div class="put-up-con"></div>
    <div class="put-up-btn">
        <%--<a class="keep-buy" href="javascript:;">继续购买</a>--%>
        <a class="check" href="javascript:void(0);" onclick="closeHit();">关闭</a>
        <div class="cl"></div>
    </div>
</div>


<%@ include file="/website/common/foot-site.jsp" %>

<script src="${webctx }/js/Global.js"></script>
<script src="${ctx }/plugins/msgTips/js/msgTips.js"></script>

<script>
    var get_coupon = false;
    function getCoupon(data) {
        if (get_coupon) {
            return false;
        }
        get_coupon = true;
        $w.httpRequest({
            url: ctx + "/coupon/receive/" + data,
            ok: function (ret) {
                if (!ret.Data) {
                    $("#click" + data).text("已领取");
                    $("#click" + data).attr("href", "javascript:void(0);");
                }
                $(".put-up-con").html("领取成功");
                $(".put-up-window").show();
            },
            fail: function (ret) {
                $(".put-up-con").html(ret.MsgDesc);
                $(".put-up-window").show();
            }
            all: function () {
                get_coupon = false;
            }
        })
    }
    function searchProduct() {
        var val = document.getElementById("topsearchtitle").value;
        if (val == $('#topsearchtitle').attr("placeholder")) val = "";
        if (val) {
            var url = ctx + "/product/list?querylike=" + encodeURI(encodeURI(val));
            if (window.location.href.indexOf("/product/list") != -1)
                window.location.href = url
            else window.open(url);
        }
    }
    function closeHit() {
        $(".put-up-window").hide();
    }
    var selcarts = [];
    var totalprice;
    $(function () {
        $('.J_select').each(function () {
            if ($(this).prev().get(0).checked)
                $(this).parent().addClass('checked');
        })
        selall(true);
        computejies();
    })


    $('.cart-item').on('click', '.productbox', function () {
        if ($(this).hasClass("checked")) {
            checkbox($(this), false);
            $(".allbox").each(function () {
                checkbox($(this), false);
            })
        } else {
            checkbox($(this), true);
            var count = 0;
            $(".productbox.checked").map(function () {
                count++;
            })
            $(".allbox").each(function () {
                checkbox($(this), count == $("[name='count']").val());
            })
        }

        $(this).find("[name='cartcheckbox']").click();
        computejies();
    });
    $(".allbox").click(function () {
        var ischeck = true;
        if ($(this).hasClass("checked")) {
            ischeck = false;
        }
        $w.httpRequest({
            url: "${ctx}/order/toggleAll",
            data: {"price": $("[name='allTotalPrice']").val(), "flag": ischeck},
            ok: function (ret) {
                $("#heji").text(ret.Data);
                $("em[id^='price']").text(0);
            }
        })
        selall(ischeck);
        computejies();
        if (ischeck) {
            window.location.href = ctx + "/order/shopcart";
        }
    });
    function checkbox(obj, ischeck) {
        if (ischeck) {
            if (obj.get(0).className.indexOf("checked") == -1) {
                obj.addClass("checked");
            }
        } else obj.removeClass("checked");
        $("[name='cartcheckbox']", obj).get(0).checked = ischeck;

    }

    function selall(ischeck) {
        $(".allbox").each(function () {
            checkbox($(this), ischeck);
        })
        $(".productbox").each(function () {
            checkbox($(this), ischeck);
        })
    }

    //计算结算
    function computejies() {
        var num = 0;
        selcarts = [];
        var boxs = $(".productbox");
        for (var i = 0; i < boxs.length; i++) {
            var boxItem = boxs.get(i);
            if ($(boxItem).hasClass("checked")) {
                num++;
//                selcarts.push({
//                    "cartid": box.value,
//                    "num": $("[name='buynumInp']", $("[cartid=" + box.value + "]")).val()
//                });
            }
        }

//        $(".productbox").each(function () {
//            if ($(this).hasClass("checked")) {
//                num++;
//                selcarts.push({
//                    "cartid": box.value,
//                    "num": $("[name='buynumInp']", $("[cartid=" + box.value + "]")).val()
//                });
//            }
//        });

        $("#sumnum").text(num);
    }

    function computexiaoji(cid) {
        var par = $("[cartid='" + cid + "']");
        if ($("[name='buynumInp']", par).val()) {
            var num = parseInt($("[name='buynumInp']", par).val());
            var price = parseFloat(par.attr("price"));
            var sum = (price * num).toFixed(2);
            return sum;
        } else return 0;
    }

    function toggleChecked(event, type, id, cid, pid, obj) {
        var n = $("#" + pid).val();
        var price = $("#price" + id).text();
        if (id == null) {
            price = $("#price" + cid).text();
        }
        if ($(obj).parent(".productbox").hasClass("checked")) {
            synToggle(type, id, cid, pid, n, price, true);
        } else {
            synToggle(type, id, cid, pid, n, price, false);
        }
        event.stopPropagation();
    }

    function addamount(type, id, cid, pid, obj) {
        var txt = $("[name='buynumInp']", $(obj).parent());
        var n = parseInt(txt.val());
        n++;
        txt.val(n);
        inputAmount(type, id, cid, pid, txt);
    }

    function lessenamount(type, id, cid, pid, obj) {
        var txt = $("[name='buynumInp']", $(obj).parent());
        var n = parseInt(txt.val());
        n--;
        txt.val(n);
        inputAmount(type, id, cid, pid, txt);
    }

    function inputAmount(type, id, cid, pid, obj) {
        $(obj).val($(obj).val().replace(/[^0-9]/g, ''));
        if ($(obj).val() == '0' || $(obj).val() == '') $(obj).val('1');
        if ($(obj).attr("maxnum") && $(obj).val()) {
            var max = parseInt($(obj).attr("maxnum"));
            max = max > 0 ? max : 0;
            if (parseInt($(obj).val()) > max) $(obj).val(max);
        }
        if ($(obj).parents(".drug-item").find(".productbox").hasClass("checked")) {
            var price = $("#price" + id).text();
            if (id == null) {
                price = $("#price" + cid).text();
            }
            synBuyCount(type, id, cid, pid, $(obj).val(), price, true);
        }
    }

    var submiting = false;
    function tojies() {
        var items = [];
        $(".cart-item").find(".productbox.checked").each(function () {
            var item = {};
            var cart = $(this).parents(".drug-item").find(".buy-numInp");
            item["id"] = cart.attr("cartId")
            item["productid"] = cart.attr("id");
            item["count"] = cart.val();
            items.push(item);
        })

        if (submiting)return;
        submiting = true;

        $("#btn_submit_form").addClass("btn_loading");

        $.ajax({
            url: apiroot + "/order/generateorder",
            type: "POST",
            dataType: "json",
            contentType: 'application/json;charset=utf-8',
            data: JSON.stringify(items),
            success: function (ret) {
                var data = ret.Data;
                if (ret.MsgCode == '-1') {
                    window.location.href = "${ctx}/user/showlogin";
                } else if (ret.MsgCode == '1') {
                    if (!data.isInventoryChange) {
                        window.location.href = ctx + "/order/orderconfirm?ordercode=" + data.orderCode;
                    } else {
                        alert("购物车信息发生变动，点击“确定”刷新购物车！");
                        window.location.reload();
                    }
                } else if (ret.MsgCode == '101') {
                    var h = "以下商品库存不足：";
                    var list = window.eval(ret.MsgDesc);
                    for (var i = 0; i < list.length; i++) {
                        var name = list[i].name ? list[i].name : list[i].productname;
                        h += "\r\n" + (i + 1) + "、" + name;
                    }
                    $(".put-up-con").html(h);
                    $(".put-up-window").show();
                } else if (ret.MsgCode == '4011') {
                    var h = "商品";
                    var list = window.eval(ret.MsgDesc);
                    for (var i = 0; i < list.length; i++) {
                        var name = list[i].name ? list[i].name : list[i].productname;
                        h += "【" + name + "】";
                    }
                    h += "超出限购";
                    $(".put-up-con").html(h);
                    $(".put-up-window").show();
                } else if (ret.MsgCode == '102') {
                    var h = "以下商品已下架：";
                    var list = window.eval(ret.MsgDesc);
                    for (var i = 0; i < list.length; i++) {
                        var name = list[i].name ? list[i].name : list[i].productname;
                        h += "\r\n" + (i + 1) + "、" + name;
                    }
                    $(".put-up-con").html(h);
                    $(".put-up-window").show();
                } else if (ret.MsgCode == '103') {
                    var h = "以下商品已不在您的可购范围：";
                    var list = window.eval(ret.MsgDesc);
                    for (var i = 0; i < list.length; i++) {
                        var name = list[i].name ? list[i].name : list[i].productname;
                        h += "\r\n" + (i + 1) + "、" + name;
                    }
                    $(".put-up-con").html(h);
                    $(".put-up-window").show();
                } else {
                    $(".put-up-con").html(ret.MsgDesc);
                    $(".put-up-window").show();
                }
            },
            error: function (ret) {
                window.location.href = "${ctx}/user/showlogin";
            },
            complete: function () {
                submiting = false;
                $("#btn_submit_form").removeClass("btn_loading");
            }
        })
    }

    function delCarts() {
        if (confirm("确定移除？")) {
            var ids = $(".productbox.checked").map(function () {
                return $("[name='cartcheckbox']", $(this)).val();
            }).get();
            $w.httpRequest({
                url: apiroot + "/order/delCart",
                data: {"ids": ids},
                ok: function (ret) {
                    window.location.href = ret.Data;
                }
            })
        }
    }

    function delCart(cid) {
        if (confirm("确定移除？")) {
            var ids = [];
            ids.push(cid);
            $w.httpRequest({
                url: apiroot + "/order/delCart",
                data: {"ids": ids},
                ok: function (ret) {
                    window.location.href = ret.Data;
                }
            })
        }
    }

    function addOften(pid, obj) {
        if ($(obj).attr("isadd") == "true") {
            $w.httpRequest({
                url: apiroot + '/product/favorite',
                data: {"priceid": pid, "action": 0},
                ok: function (ret) {
                    $(obj).text("已收藏");
                    msgTips_success("收藏成功");
                    $(obj).attr("isadd", "false");
                }
            })
        } else {
            $w.httpRequest({
                url: apiroot + "/product/favorite",
                data: {"priceid": pid, "action": 1},
                ok: function (ret) {
                    $(obj).text("收藏");
                    msgTips_success("取消收藏成功");
                    $(obj).attr("isadd", "true");
                }
            })
        }

    }
    function synToggle(type, id, cid, pid, count, price, flag) {
        toggleCartItems(type, id, cid, pid, count, price, flag);
    }

    var toggle_click = false;
    function toggleCartItems(type, id, cid, pid, count, price, flag) {
        if (toggle_click) {
            return false;
        }
        toggle_click = true;
        $.ajax({
            type: "get",
            url: "${ctx}/order/toggleCart",
            dataType: "json",
            data: {
                "promotionType": type,
                "promotionId": id,
                "id": cid,
                "productid": pid,
                "count": count,
                "price": price,
                "check": flag
            },
            success: function (ret) {
                var data = ret.Data;
                splice(data);
                $("#heji").text(data.price);
            },
            complete: function () {
                toggle_click = false;
            }
        })
    }

    var synBuyCountCache = {};
    var synBuyCountTimer = {};
    function synBuyCount(type, id, cid, pid, count, price, flag) {
        var buycount = count + '';
        var buycountCache = synBuyCountCache[pid + ''] + '';
        if (buycount == buycountCache) {
            return true;
        } else {
            synBuyCountCache[pid + ''] = buycount;
            var synBuyCountTimerPre = synBuyCountTimer[pid + ''];
            if (synBuyCountTimerPre > 0) {
                window.clearTimeout(synBuyCountTimerPre);
                synBuyCountTimer[pid + ''] = -1;
            }
            var synBuyCountTimerTemp = window.setTimeout(function () {
                synBuyCountTimer[pid + ''] = -1;
                synCartItems(type, id, cid, pid, count, price, flag);
            }, 600);
            synBuyCountTimer[pid + ''] = synBuyCountTimerTemp;
        }
    }

    var submit = false;

    function synCartItems(type, id, cid, pid, count, price, flag) {
        if (submit)return;
        submit = true;
        $w.httpRequest({
            url: "${ctx}/order/syncart",
            data: {
                "promotionType": type,
                "promotionId": id,
                "id": cid,
                "productid": pid,
                "count": count,
                "price": price,
                "check": flag
            },
            ok: function (ret) {
                var data = ret.Data;
                splice(data);
                $("#heji").text(data.price);
            },
            all: function () {
                submit = false;
            }
        })
    }

    function splice(data) {
        var item = data.data;
        if (item == null) {
            return;
        }
        var products = item.products;
        var h = '';
        if (data.type == 'list') {
            var product = products[0];
            $("#price" + product.cartId).text(product.totalPrice);
        } else if (data.type == 'complex') {
            var product = products[0];
            $("#" + product.cartId).empty();
            h += '<div class="drug-item clearfix"><ul class="bor-no clearfix">'
                + '<li class="td td-chk"><div class="cart-checkbox productbox ';
            h += product.check ? 'checked' : '';
            h += '"><input name="cartcheckbox" type="checkbox" onclick="toggleChecked(event,' + "'complex'" + ', null, ' + product.cartId + ', ' + product.id + ', this);" value="' + product.cartId + '"><label class="J_select"></label></div></li>'
                + '<li class="drug-img"><a target="_blank" href="' + ctx + "/product/info?priceid=" + product.id + '"><img src="' + getRandomFileserver() + product.photo + '" alt="" onerror="this.src=' + "'/website/images/noimg.jpg'" + '"></a></li>'
                + '<li class="drug-info"><p class="drug-info-name">' + product.name + '</p><p class="ph drug-info-company">厂家： ' + product.b_chanjia + '</p><p class="ph drug-info-size">规格： ' + product.b_guige + '</p></li>'
                + '<li class="drug-price"><p>￥' + product.price + '</p>';
            h += product.flashSale && product.flashSaleAvailableInventory != '' ? '<p class="cart-red">限购' + product.flashSaleAvailableInventory + '件</p>' : '';
            h += '</li>'
                + '<li class="drug-amount td-amount"><div class="buy-Num-bd across">'
                + '<input cartid="' + product.cartId + '" id="' + product.id + '" name="buynumInp"type="text"class="buy-numInp"style="float:left;height:26px;line-height:26px;"value="' + product.buyNum
                + '"onblur="inputAmount(' + "'complex'" + ', null, ' + product.cartId + ', ' + product.id + ', this);" maxnum="' + product.amount +
                '"><span class="btn-reduce"onclick="lessenamount(' + "'complex'" + ',null, ' + product.cartId + ', ' + product.id + ', this);">-</span>'
                + '<span class="btn-add"onclick="addamount(' + "'complex'" + ', null, ' + product.cartId + ', ' + product.id + ', this);">+</span>'
                + '<span class="buy-txt">' + product.unit + '</span></div>'
                + '<p class="drug-repertory">库存：';
            if (product.amount > 100) {
                h += '>100';
            } else if (product.amount > 0) {
                h += product.amount;
            } else {
                h += '无';
            }
            h += '</p></li>'
                + '<li class="drug-sum"><p>￥<em id="price' + product.cartId + '">' + product.totalPrice + '</em></p></li>'
                + '<li class="drug-op">';
            if (product.often) {
                h += '<p isadd="false" onclick="addOften(' + product.id + ',this)">已收藏</p>';
            } else {
                h += '<p isadd="true" onclick="addOften(' + product.id + ',this)">收藏</p>';
            }
            h += '<p onclick="delCart(' + product.cartId + ');">删除</p></li>'
                + '</ul><div class="cl"></div>';
            if (product.buySend) {
                h += '<p class="give-shop-txt">';
                if (product.available) {
                    h += '<em class="cart-red">买送：</em>' + product.name + product.b_guige + "×" + product.giftNum;
                } else {
                    h += '<em class="cart-red">买送：</em>买' + product.standardNum + "送" + product.sendNum;
                }
                h += '</p>';
            }
            h += '</div>';
            $("#" + product.cartId).html(h);
        } else if (data.type == 'purchase_gift') {
            $("#" + data.data.promotionId).empty();
            for (var i = 0; i < products.length; i++) {
                var product = products[i];
                if (product.giftType) {
                    if (product.gift) {
                        h += '<div class="drug-item give-shop clearfix"><ul>'
                            + '<li class="td td-chk th-disabled"><span></span></li>'
                            + '<li class="drug-img"><a target="_blank" href="' + ctx + "/product/info?priceid=" + product.id + '"><img src="' + getRandomFileserver() + product.photo + '" alt="" onerror="this.src=' + "'/website/images/noimg.jpg'" + '"></a></li>'
                            + '<li class="drug-info"><p class="drug-info-name"><span class="give-sp">赠品</span>' + product.name + '</p><p class="ph drug-info-company">厂家： ' + product.b_chanjia + '</p><p class="ph drug-info-size">规格： ' + product.b_guige + '</p></li>'
                            + '<li class="drug-price"><p>￥0.00</p></li>'
                            + '<li class="drug-amount td-amount"><p>' + product.buyNum + '</p>';
                        h += product.shortage ? '<p class="drug-repertory cart-red">库存不足</p>' : '';
                        h += '</li>'
                            + '<li class="drug-sum"><p>￥0.00</p></li>'
                            + '<li class="drug-op"></li>'
                            + '</ul></div>'
                    }
                } else {
                    h += '<div class="drug-item clearfix"><ul class="bor-no clearfix">'
                        + '<li class="td td-chk"><div class="cart-checkbox productbox ';
                    h += product.check ? 'checked' : '';
                    h += '"><input name="cartcheckbox" type="checkbox" onclick="toggleChecked(event,' + "'purchase_gift'" + ', ' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);" value="' + product.cartId + '"><label class="J_select"></label></div></li>'
                        + '<li class="drug-img"><a target="_blank" href="' + ctx + "/product/info?priceid=" + product.id + '"><img src="' + getRandomFileserver() + product.photo + '" alt="" onerror="this.src=' + "'/website/images/noimg.jpg'" + '"></a></li>'
                        + '<li class="drug-info"><p class="drug-info-name">' + product.name + '</p><p class="ph drug-info-company">厂家： ' + product.b_chanjia + '</p><p class="ph drug-info-size">规格： ' + product.b_guige + '</p></li>'
                        + '<li class="drug-price"><p>￥' + product.price + '</p>';
                    h += product.flashSale && product.flashSaleAvailableInventory != '' ? '<p class="cart-red">限购' + product.flashSaleAvailableInventory + '件</p>' : '';
                    h += '</li>'
                        + '<li class="drug-amount td-amount"><div class="buy-Num-bd across">'
                        + '<input cartid="' + product.cartId + '" id="' + product.id + '" name="buynumInp"type="text"class="buy-numInp"style="float:left;height:26px;line-height:26px;"value="' + product.buyNum + '"onblur="inputAmount(' + "'purchase_gift'" + ', ' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);" maxnum="' + product.amount
                        + '"><span class="btn-reduce"onclick="lessenamount(' + "'purchase_gift'" + ',' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);">-</span>'
                        + '<span class="btn-add"onclick="addamount(' + "'purchase_gift'" + ', ' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);">+</span>'
                        + '<span class="buy-txt">' + product.unit + '</span></div>'
                        + '<p class="drug-repertory">库存：';
                    if (product.amount > 100) {
                        h += '>100';
                    } else if (product.amount > 0) {
                        h += product.amount;
                    } else {
                        h += '无';
                    }
                    h += '</p></li>'
                        + '<li class="drug-sum"><p>￥<span id="xiaoji' + product.cartId + '">' + product.totalPrice + '</span></p></li>'
                        + '<li class="drug-op">';
                    if (product.often) {
                        h += '<p isadd="false" onclick="addOften(' + product.id + ',this)">已收藏</p>';
                    } else {
                        h += '<p isadd="true" onclick="addOften(' + product.id + ',this)">收藏</p>';
                    }
                    h += '<p onclick="delCart(' + product.cartId + ');">删除</p></li>'
                        + '</ul><div class="cl"></div>';
                    h += product.buySend ? '<p class="give-shop-txt"><em class="cart-red">买送：</em>' + product.name + ' ×' + product.sendNum + '</p>' : '' + '</div>';
                }
            }
            $("#" + data.data.promotionId).html(h);
            if (item.standardMoney) {
                $("#standardMoney" + item.promotionId).text(item.standardMoney);
            } else {
                $("#standardMoney" + item.promotionId).text(item.standardAmount);
            }

            if (item.hasStandard == true) {
                $("#giftText" + data.data.promotionId).text("已获得赠品");
            } else {
                $("#giftText" + data.data.promotionId).text("可获得赠品");
            }

            $("#number" + data.data.promotionId).text(data.data.number);
            $("#price" + data.data.promotionId).text(data.data.totalPrice);
        } else if (data.type == 'money_off') {
            $("#" + item.promotionId).empty();
            h += '<div class="item-tit"><span>满减</span>';
            if (item.available) {
                h += " 活动已购满" + item.standardMoney;
                h += '，<em class="cart-red">';
                if (item.discountRate > 0) {
                    h += '已打' + item.discountRate + '折';
                } else {
                    h += '已减' + item.discountMoney + '元';
                }
                h += "</em>";
            } else {
                h += "活动";
                var rules = item.items;
                for (var i = 0; i < rules.length; i++) {
                    var rule = rules[i];
                    h += "满" + rule.offMoney;
                    if (rule.discountRate > 0) {
                        h += '打' + rule.discountRate + '折,';
                    } else {
                        h += '减' + rule.discountMoney + ',';
                    }
                }
            }
            h += '<div class="item-sum item-sum-lig"><em style="display: none" id="price' + item.promotionId + '">' + item.totalPrice + '</em><p style="padding-left: 14px">￥' + item.minuendPrice + '</p>';
            h += item.available ? '<p class="cart-red">减￥' + item.discountMoney + '</p>' : '';
            h += '</div></div><div class="item-drug-list">';
            for (var i = 0; i < products.length; i++) {
                var product = products[i];
                if (product.giftType) {
                    if (product.gift) {
                        h += '<div class="drug-item give-shop clearfix"><ul>'
                            + '<li class="td td-chk th-disabled"><span></span></li>'
                            + '<li class="drug-img"><a target="_blank" href="' + ctx + "/product/info?priceid=" + product.id + '"><img src="' + getRandomFileserver() + product.photo + '" alt="" onerror="this.src=' + "'/website/images/noimg.jpg'" + '"></a></li>'
                            + '<li class="drug-info"><p class="drug-info-name"><span class="give-sp">赠品</span>' + product.name + '</p><p class="ph drug-info-company">厂家： ' + product.b_chanjia + '</p><p class="ph drug-info-size">规格： ' + product.b_guige + '</p></li>'
                            + '<li class="drug-price"><p>￥0.00</p></li>'
                            + '<li class="drug-amount td-amount"><p>' + product.buyNum + '</p>';
                        h += product.shortage ? '<p class="drug-repertory cart-red">库存不足</p>' : '';
                        h += '</li>'
                            + '<li class="drug-sum"><p>￥0.00</p></li>'
                            + '<li class="drug-op"></li>'
                            + '</ul></div>'
                    }
                } else {
                    h += '<div class="drug-item clearfix"><ul class="bor-no clearfix">'
                        + '<li class="td td-chk"><div class="cart-checkbox productbox ';
                    h += product.check ? 'checked' : '';
                    h += '"><input name="cartcheckbox" type="checkbox" onclick="toggleChecked(event,' + "'money_off'" + ', ' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);" value="' + product.cartId + '"><label class="J_select"></label></div></li>'
                        + '<li class="drug-img"><a target="_blank" href="' + ctx + "/product/info?priceid=" + product.id + '"><img src="' + getRandomFileserver() + product.photo + '" alt="" onerror="this.src=' + "'/website/images/noimg.jpg'" + '"></a></li>'
                        + '<li class="drug-info"><p class="drug-info-name">' + product.name + '</p><p class="ph drug-info-company">厂家： ' + product.b_chanjia + '</p><p class="ph drug-info-size">规格： ' + product.b_guige + '</p></li>'
                        + '<li class="drug-price"><p>￥' + product.price + '</p>';
                    h += product.flashSale && product.flashSaleAvailableInventory != '' ? '<p class="cart-red">限购' + product.flashSaleAvailableInventory + '件</p>' : '';
                    h += '</li>'
                        + '<li class="drug-amount td-amount"><div class="buy-Num-bd across">'
                        + '<input cartid="' + product.cartId + '" id="' + product.id + '" name="buynumInp"type="text"class="buy-numInp"style="float:left;height:26px;line-height:26px;"value="' + product.buyNum + '"onblur="inputAmount(' + "'money_off'" + ', ' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);" maxnum="' + product.amount
                        + '"><span class="btn-reduce"onclick="lessenamount(' + "'money_off'" + ',' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);">-</span>'
                        + '<span class="btn-add"onclick="addamount(' + "'money_off'" + ', ' + item.promotionId + ', ' + product.cartId + ', ' + product.id + ', this);">+</span>'
                        + '<span class="buy-txt">' + product.unit + '</span></div>'
                        + '<p class="drug-repertory">库存：';
                    if (product.amount > 100) {
                        h += '>100';
                    } else if (product.amount > 0) {
                        h += product.amount;
                    } else {
                        h += '无';
                    }
                    h += '</p></li>'
                        + '<li class="drug-sum"><p>￥<span id="xiaoji' + product.cartId + '">' + product.totalPrice + '</span></p></li>'
                        + '<li class="drug-op">';
                    if (product.often) {
                        h += '<p isadd="false" onclick="addOften(' + product.id + ',this)">已收藏</p>';
                    } else {
                        h += '<p isadd="true" onclick="addOften(' + product.id + ',this)">收藏</p>';
                    }
                    h += '<p onclick="delCart(' + product.cartId + ');">删除</p></li>'
                        + '</ul><div class="cl"></div>';
                    if (product.buySend) {
                        h += '<p class="give-shop-txt">';
                        if (product.available) {
                            h += '<em class="cart-red">买送：</em>' + product.name + product.b_guige + "×" + product.giftNum;
                        } else {
                            h += '<em class="cart-red">买送：</em>买' + product.standardNum + "送" + product.sendNum;
                        }
                        h += '</p>';
                    }
                    h += '</div>';
                }
            }
            h += '</div></div>';
            $("#" + item.promotionId).html(h);
        }
    }

    function cl_coupon(obj) {
        var obj_d = $(obj).next(".get-coupon");
        if (obj_d.is(":hidden")) {
            $(".get-coupon").hide();
            obj_d.show();
        } else {
            $(".get-coupon").hide();
        }
    };
    $(document).click(function () {
        $(".get-coupon").hide();
    });
    $(".coupon-btn span").click(function (event) {
        event.stopPropagation();
    });
    $(".get-coupon").click(function (event) {
        event.stopPropagation();
    });


</script>
</body>
</html>